package me.zhengjie.modules.logs.domain;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import me.zhengjie.tool.DateUtil;
import me.zhengjie.tool.MyMap;
import me.zhengjie.tool.NPETool;
import me.zhengjie.tool.ValidateUtil;
import me.zhengjie.utils.SecurityUtils;
import me.zhengjie.vo.Constant;

import java.io.Serializable;
import java.util.Map;


/**
 * 业务日志
 */
@ApiModel("BusinessLog")
@Data
public class BusinessLog implements Serializable {

    private static final long serialVersionUID = 3613448089274445709L;

    @ApiModelProperty("业务日志id")
    private String aaz002;

    @ApiModelProperty("批量业务拆分成单条任务id")
    private String aaz005;

    @ApiModelProperty("单位编号")
    private String aab001;

    @ApiModelProperty("单位名称")
    private String aab004;

    @ApiModelProperty("个人编号")
    private String aac001;

    @ApiModelProperty("证件号码")
    private String aac002;

    @ApiModelProperty("姓名")
    private String aac003;

    @ApiModelProperty("险种")
    private String aae140;

    @ApiModelProperty("复核标志")
    private String aae016;

    @ApiModelProperty("经办人")
    private String aae011;

    @ApiModelProperty("经办时间")
    private String aae036;

    @ApiModelProperty("复核人")
    private String aae014;

    @ApiModelProperty("复核时间")
    private String aae015;

    @ApiModelProperty("参保所属机构")
    private String aab359;

    @ApiModelProperty("业务类型")
    private String aaa121;

    @ApiModelProperty("所属省份")
    private String aaf018;

    @ApiModelProperty("备注")
    private String aae013;

    @ApiModelProperty("撤销原因")
    private String aae017;

    @ApiModelProperty("金额")
    private String aae719;

    @ApiModelProperty("撤销人")
    private String aae018;

    @ApiModelProperty("撤销时间")
    private String aae019;

    /**
     * 构造方法
     */
    public BusinessLog(){

    }


    /**
     * 构造方法
     */
    public BusinessLog(
            String aaz002,
            String aaa121,
            String aab001,
            String aab004,
            String aac001,
            String aac002,
            String aac003,
            String aae140,
            String aae016,
            String aae011,
            String aae036,
            String aae014,
            String aae015,
            String aae013,
            String aab359,
            String aae017,
            String aae018,
            String aae019
            ) {
        NPETool.isEmptyThrowException(aaz002, "业务日志id");
        NPETool.isEmptyThrowException(aaa121, "业务类型");
                this.aaz002  = aaz002;
                this.aaa121  = aaa121;
                this.aab001  = aab001;
                this.aab004  = aab004;
                this.aac001  = aac001;
                this.aac002  = aac002;
                this.aac003  = aac003;
                this.aae140  = aae140;
                this.aae016  = aae016;
                this.aae011  = aae011;
                this.aae036  = aae036;
                this.aae014  = aae014;
                this.aae015  = aae015;
                this.aae013  = aae013;
                this.aab359 = aab359;
                this.aae017 = aae017;
                this.aae018 = aae018;
                this.aae019 = aae019;
                // 设置默认值
        if (ValidateUtil.isEmpty(aae011)) {
            this.aae011 = SecurityUtils.getCurrentUsername();
        }
        if (ValidateUtil.isEmpty(aae036)) {
            this.aae036 = DateUtil.getStringCurDateTime();
        }
        if (ValidateUtil.isEmpty(aae014)) {
            this.aae014 = SecurityUtils.getCurrentUsername();
        }
        if (ValidateUtil.isEmpty(aae015)) {
            this.aae015 = DateUtil.getStringCurDateTime();
        }
        if (ValidateUtil.isEmpty(aab359)) {
            this.aab359 = "530111";
        }if (ValidateUtil.isEmpty(aae140)) {
            this.aae140 = Constant.AAE140_120_JGSYDWGZRYJBYLBX;
        }

    }

    public static BusinessLog singleLog(Map... maps) {

        String baz001 = "";
        String aaz002 = "";

        String aaa121 = "";
        String aae140 = "";

        String aac001 = "";
        String aac002 = "";
        String aac003 = "";
        String aac058 = "";

        String aab001 = "";
        String aab004 = "";

        String userId   = "";
        String aae011 = "";
        String orgId    = "";
        String aae013   = "";

        String aab359  = "";
        String aab360  = "";
        String aaa027  = "";
        String baz002  = "";
        String aae741  = "";
        String bae012  = ""; // 数据来源
        String baz356  = "";
        String cae099  = "";

        String continueHandle  = "";
        String reason  = "";
        String yyw010 = "";
        String aaa132 = "";
        String aae016 = "";
        String aae036 = "";
        String aae014 = "";
        String aae015 = "";
        String aae017 = "";
        String aae018 = "";
        String aae019 = "";

        MyMap logMap = null;

        for (Map tmpMap : maps) {
            logMap = new MyMap(tmpMap);
            aaz002 = notNullString(logMap, aaz002, "aaz002");

            aaa121 = notNullString(logMap, aaa121, "aaa121");
            aae140 = notNullString(logMap, aae140, "aae140");

            aac001 = notNullString(logMap, aac001, "aac001");
            aac002 = notNullString(logMap, aac002, "aac002");
            aac003 = notNullString(logMap, aac003, "aac003");
            aac058 = notNullString(logMap, aac058, "aac058");

            aab001 = notNullString(logMap, aab001, "aab001");
            aab004 = notNullString(logMap, aab004, "aab004");

            userId = notNullString(logMap, userId, "aaz692");
            aae011 = notNullString(logMap, aae011, "aae011");
            aae016 = notNullString(logMap, aae016, "aae016");
            orgId = notNullString(logMap, orgId, "aab034");
            aae013 = notNullString(logMap, aae013, "aae013");
            aae014 = notNullString(logMap, aae014, "aae014");
            aae015 = notNullString(logMap, aae015, "aae015");
            aae036 = notNullString(logMap, aae036, "aae036");

            aab359 = notNullString(logMap, aab359, "aab359");
            aab360 = notNullString(logMap, aab360, "aab360");
            aaa027 = notNullString(logMap, aaa027, "aaa027");
            baz002 = notNullString(logMap, baz002, "baz002");
            aae741 = notNullString(logMap, aae741, "aae741");
            bae012 = notNullString(logMap, bae012, "bae012");
            baz356 = notNullString(logMap, baz356, "baz356");

            continueHandle = notNullString(logMap, continueHandle, "continueHandle");
            reason = notNullString(logMap, reason, "reason");
            yyw010 = notNullString(logMap, yyw010, "yyw010");
            aaa132 = notNullString(logMap, aaa132, "aaa132");
            cae099 = notNullString(logMap, cae099, "cae099");
            aae017 = notNullString(logMap, aae017, "aae017");
            aae018 = notNullString(logMap, aae018, "aae018");
            aae019 = notNullString(logMap, aae019, "aae019");
        }


        BusinessLog businessLog = new BusinessLog(
                aaz002,
                aaa121,
                aab001,
                aab004,
                aac001,
                aac002,
                aac003,
                aae140,
                aae016,
                aae011,
                aae036,
                aae014,
                aae015,
                aae013,
                aab359,
                aae017,
                aae018,
                aae019
        );
        return businessLog;
    }

    private static String notNullString(MyMap logMap, String initString, String colName) {
        if (ValidateUtil.isEmpty(initString)) {
            return logMap.getAsString(colName);
        } else {
            return initString;
        }
    }

}
